package com.itheima.stock.config;

import com.google.common.util.concurrent.RateLimiter;
import com.itheima.stock.properties.IdWorkProperties;
import com.itheima.stock.properties.LimiterProperties;
import com.itheima.stock.util.IdWorkers;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 * 流量控制生成器配置类
 */
@Configuration
@SuppressWarnings("all")
public class LimiterConfig {

    @Bean
    public RateLimiter rateLimiter(LimiterProperties properties){//每秒生成n个令牌
        return RateLimiter.create(properties.getConcurrentNum());
    }

}
